//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;

namespace OpenLS.Spreadsheet.Data
{
    partial class DataConnection
    {
        struct ConnectionAttributes
        {
            internal void ReadAttributes(ReadContext c)
            {
                Id = c.GetUIntegerAsInteger("id");
                SourceFile = c.GetOptionalString("sourceFile");
                OdcFile = c.GetOptionalString("odcFile");
                KeepAlive = c.GetOptionalBoolean("keepAlive", false);
                Interval = c.GetOptionalUIntegerAsInteger("interval", 0);
                Name = c.GetOptionalString("name");
                Description = c.GetOptionalString("description");
                Type = (DataConnectionType) c.GetOptionalUIntegerAsInteger("type", 0);
                ReconnectionMethod = c.GetOptionalUIntegerAsInteger("reconnectionMethod", 1);
                RefreshedVersion = c.GetInteger("refreshedVersion");
                MinRefreshableVersion = c.GetOptionalInteger("minRefreshableVersion", 0);
                SavePassword = c.GetOptionalBoolean("savePassword", false);
                IsNew = c.GetOptionalBoolean("new", false);
                IsDeleted = c.GetOptionalBoolean("deleted", false);
                OnlyUseConnectionFile = c.GetOptionalBoolean("onlyUseConnectionFile", false);
                Background = c.GetOptionalBoolean("background", false);
                RefreshOnLoad = c.GetOptionalBoolean("refreshOnLoad", false);
                SaveData = c.GetOptionalBoolean("saveData", false);
                Credentials = c.GetOptionalEnum("credentials", CredentialsMethod.Integrated);
                SingleSignOnId = c.GetOptionalString("singleSignOnId");
            }
            private int _id;

            public int Id
            {
                get { return _id; }
                set { _id = value; }
            }
            private string _sourceFile;

            public string SourceFile
            {
                get { return _sourceFile; }
                set { _sourceFile = value; }
            }
            private string odcFile;

            public string OdcFile
            {
                get { return odcFile; }
                set { odcFile = value; }
            }
            private bool keepAlive;

            public bool KeepAlive
            {
                get { return keepAlive; }
                set { keepAlive = value; }
            }
            private int interval;

            public int Interval
            {
                get { return interval; }
                set { interval = value; }
            }
            private string name;

            public string Name
            {
                get { return name; }
                set { name = value; }
            }
            private string description;

            public string Description
            {
                get { return description; }
                set { description = value; }
            }
            private DataConnectionType _type;

            public DataConnectionType Type
            {
                get { return _type; }
                set { _type = value; }
            }
            private int reconnectionMethod;

            public int ReconnectionMethod
            {
                get { return reconnectionMethod; }
                set { reconnectionMethod = value; }
            }
            private int refreshedVersion;

            public int RefreshedVersion
            {
                get { return refreshedVersion; }
                set { refreshedVersion = value; }
            }
            private int minRefreshableVersion;

            public int MinRefreshableVersion
            {
                get { return minRefreshableVersion; }
                set { minRefreshableVersion = value; }
            }
            private bool savePassword;

            public bool SavePassword
            {
                get { return savePassword; }
                set { savePassword = value; }
            }
            private bool _new;

            public bool IsNew
            {
                get { return _new; }
                set { _new = value; }
            }
            private bool deleted;

            public bool IsDeleted
            {
                get { return deleted; }
                set { deleted = value; }
            }
            private bool onlyUseConnectionFile;

            public bool OnlyUseConnectionFile
            {
                get { return onlyUseConnectionFile; }
                set { onlyUseConnectionFile = value; }
            }
            private bool _background;

            public bool Background
            {
                get { return _background; }
                set { _background = value; }
            }
            private bool _refreshOnLoad;

            public bool RefreshOnLoad
            {
                get { return _refreshOnLoad; }
                set { _refreshOnLoad = value; }
            }
            private bool _saveData;

            public bool SaveData
            {
                get { return _saveData; }
                set { _saveData = value; }
            }
            private CredentialsMethod credentials;

            public CredentialsMethod Credentials
            {
                get { return credentials; }
                set { credentials = value; }
            }
            private string singleSignOnId;

            public string SingleSignOnId
            {
                get { return singleSignOnId; }
                set { singleSignOnId = value; }
            }


            internal void CopyTo(DataConnection result)
            {
                result.Id = Id ;
                result.SourceFile = SourceFile ;
                result.OdcFile = OdcFile ;
                result.KeepAlive = KeepAlive ;
                result.Interval = Interval ;
                result.Name = Name ;
                result.Description = Description ;
                result.Type = Type ;
                result.ReconnectionMethod = ReconnectionMethod ;
                result.RefreshedVersion = RefreshedVersion ;
                result.MinRefreshableVersion = MinRefreshableVersion ;
                result.SavePassword = SavePassword ;
                result.IsNew = IsNew;
                result.IsDeleted = IsDeleted;
                result.OnlyUseConnectionFile = OnlyUseConnectionFile;
                result.Background = Background;
                result.RefreshOnLoad = RefreshOnLoad;
                result.SaveData = SaveData;
                result.Credentials = Credentials;
                result.SingleSignOnId = SingleSignOnId;
            }
        }
    }
}
